/**
 * @param {string[]} words1
 * @param {string[]} words2
 * @return {number}
 */
// 计数一般使用hash表
var countWords = function (words1, words2) {
    let w1 = new Map(), w2 = new Map()
    for (let i = 0; i < words1.length; i++) {
        let item = words1[i]
        if (w1.has(item)) w1.set(item, w1.get(item) + 1)
        else w1.set(item, 1)
    }
    for (let i = 0; i < words2.length; i++) {
        let item = words2[i]
        if (w2.has(item)) w2.set(item, w2.get(item) + 1)
        else w2.set(item, 1)
    }
    let ans = 0
    for (let [key, value] of w1) {
        if (value == 1 && w2.has(key) && w2.get(key) == 1) ans++
    }
    return ans
};